
 import React, { Component } from "react";
 import {getCode} from '../../api/bms/login'
class ImageCode extends Component  {
    constructor() {
        super();
        this.state = {}
    }
    renderCode(){
        getCode(Math.round(Math.random()*100000+1),localStorage.getItem("SID")).then((res) =>{
            let img = document.getElementById("imgCode");
            let binaryData = [];
            binaryData.push(res);
            img.src = window.URL.createObjectURL(new Blob(binaryData, {type: "image/jpeg"}));
        })
    }
    componentDidMount(){
        this.renderCode();
    }
    render(){
        return( 
            <img id ="imgCode" alt="验证码" onClick={this.renderCode}></img>
      )
    }
}

export default ImageCode;